import 'package:flutter/material.dart';
import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:share_fit/app/components/back_btn_icon.dart';
import 'package:share_fit/app/helper/ext/tr_ext.dart';
import 'package:share_fit/app/tools/color_const.dart';
import 'package:share_fit/generated/locales.g.dart';

import 'settings_sos_logic.dart';

class SettingsSosAddPage extends StatelessWidget {
  SettingsSosAddPage({super.key});

  final logic = Get.put(SettingsSosLogic());
  final state = Get.find<SettingsSosLogic>().state;
  final FlutterContactPicker _contactPicker = FlutterContactPicker();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          title: Text(LocaleKeys.sos_number_add.ts, style: TextStyle(fontSize: 54.sp),),
          centerTitle: true,
          leading: BackBtnIcon(onTap: () => Get.back())
      ),
      body: Padding(
          padding: EdgeInsets.only(left: 40.w, top: 80.h, right: 40.w),
          child: ListView(
            children: [
              Ink(
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(20),
                ),
                child: InkResponse(
                  splashColor: ColorConst.activeColor,
                  borderRadius: BorderRadius.circular(20),
                  highlightShape: BoxShape.rectangle,
                  highlightColor: ColorConst.activeColor,
                  containedInkWell: true,
                  child: Container(
                    height: 175.h,
                    padding: EdgeInsets.only(left: 59.w, right: 36.w),
                    child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            LocaleKeys.sos_number_from_contacts.ts,
                            style: TextStyle(
                                fontSize: 42.sp,
                                color: ColorConst.primaryFontColor),
                          ),
                        ]),
                  ),
                  onTap: () async {
                    // Contact? contact = await _contactPicker.selectContact();
                    // if (contact != null && contact.phoneNumbers != null) {
                    //   String name = contact.fullName == null ? "": contact.fullName!;
                    //   String phoneNumber = contact.phoneNumbers!.isEmpty ? "": contact.phoneNumbers![0];
                    //   if (phoneNumber.isNotEmpty) {
                    //     logic.syncSosCallInfo(name, phoneNumber, true);
                    //   }
                    //   else {
                    //     logic.showTips(LocaleKeys.info.ts, LocaleKeys.sos_number_invalid.ts);
                    //   }
                    // }
                    logic.toContactPage();

                  },
                ),
              ),
            ],
          )),
    );
  }
}
